<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户注册</title>
		<link rel="stylesheet" href="css/bootstrap.min.css">
		<style>
			.wrap{
				width: 1000px;
				margin:100px auto;
			}
		</style>
	</head>
	<body>
		<div class='wrap'>
			<h2>用户注册</h2>
			<hr>
			<div class="form-group">
				<label for="username">用户名</label>
				<input type="email" class="form-control" id="username" placeholder="请输入用户名">
			</div>
			<div class="form-group">
				<label for="password">密码</label>
				<input type="password" class="form-control" id="password" placeholder="请输入密码">
			</div>
			<div class="form-group">
				<label for="password">确认密码</label>
				<input type="password" class="form-control" id="confirm" placeholder="请再次输入密码">
			</div>
			<button type="submit" class="btn btn-primary" id="register">注册</button>
			<a href="/login.html">已有帐号，前往登录</a>
		</div>
		<script src="library/jquery.min.js"></script>
		<script>
			$("#register").click(function() {
				if ($("#username").val() && $("#password").val() && $("#confirm").val()) {
					if ($("#password").val() === $("#confirm").val()) {
						console.log(1)
						$.ajax({
							url: "http://10.35.170.110/register",
							data: {
								username: $("#username").val(),
								password: $("#password").val(),
							},
							success: function(data) {
								if (data === "success") {
									location.href = "http://10.35.170.110/login.html"
								} else {

								}
							}
						})
					} else {
						alert("两次密码输入不一致！")
					}
				} else {
					alert("请填写所有内容")
				}
			})
		</script>
	</body>
</html>
